#ifndef IO_H
#define IO_H

#include "base.h"
#include "gfx.h"
#include "sfx.h"

//
// Highscores
//

typedef struct
{
    char name[4];
    int score;
} Highscore;

const static int IO_HIGHSCORE_MAX = 10;

void io_highscore_read(Highscore *score, int id);
void io_highscore_write(Highscore *score);
void io_highscore_reset(void);
int io_highscore_eligible(int score);

//
// Input (Playstation 3 controller reference layout)

//

const static int IO_PLAYER_SELECT       =  1 << 0;
const static int IO_PLAYER_L3           =  1 << 1;
const static int IO_PLAYER_R3           =  1 << 2;
const static int IO_PLAYER_PAUSE        =  1 << 3;

const static int IO_PLAYER_TOP          =  1 << 4;
const static int IO_PLAYER_RIGHT        =  1 << 5;
const static int IO_PLAYER_BOTTOM       =  1 << 6;
const static int IO_PLAYER_LEFT         =  1 << 7;


const static int IO_PLAYER_L2           =  1 << 8;
const static int IO_PLAYER_R2           =  1 << 9;
const static int IO_PLAYER_L1           =  1 << 10;
const static int IO_PLAYER_R1           =  1 << 11;

const static int IO_PLAYER_TRIANGLE     =  1 << 12;
const static int IO_PLAYER_CIRCLE       =  1 << 13;
const static int IO_PLAYER_CROSS        =  1 << 14;
const static int IO_PLAYER_SQUARE       =  1 << 15;

const static int IO_PLAYER_HOME         =  1 << 16;

void io_player_read_buttons(void);
int io_player_get_buttons_menu(void);
int io_player_get_buttons(int player);
void io_player_get_joystick(int player, vec2 joystick);

const static int IO_MOUSE_LBUTTON   = 1 << 0;
const static int IO_MOUSE_RBUTTON   = 1 << 1;
void io_get_mouse(float *x, float *y, int *buttons_state);

//
// Initialization
//

void io_init(void);
void io_exit(void);

#endif
